package com.redstar.interesting.common.response;

import com.redstar.interesting.common.enums.EnumServerCode;

import java.io.Serializable;

/**
 * @author lihongxing
 */
public class JsonResponse implements Serializable {
    private static final long serialVersionUID = 2704677150727305980L;


    private int code;

    private Object data;

    private String msg;

    private String traceId;


    public JsonResponse() {
    }

    public JsonResponse(int code) {
        this.code = code;
        EnumServerCode instance = EnumServerCode.getInstance(code);
        this.msg = instance == null ? "" : instance.getDesc();
    }

    public JsonResponse(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public JsonResponse(int code, String msg, Object data) {
        this.data = data;
        this.code = code;
        this.msg = msg;
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
        this.code = EnumServerCode.SUCCESS.getCode();
        this.msg = EnumServerCode.SUCCESS.getDesc();
    }

    public String getMsg() {
        return msg;
    }


    public String getTraceId() {
        return traceId;
    }

    public void setTraceId(String traceId) {
        this.traceId = traceId;
    }
}
